import javax.servlet.http.*;
import java.sql.*;
import java.io.*;

public class EditServlet extends HttpServlet
{

String student_name;
             String student_id;
             String college_code;         
             String course;  

             String ssc;
             String ssc_year;
             String inter;         
             String inter_year;     
             String graduation;
             String graduation_year;
             String pg;         
             String pg_year; 

            
  
  public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException
  {

    
 
        String student_id=request.getParameter("student_id");
       

         response.setContentType("text/html");
         PrintWriter out=response.getWriter();

          try
       {
        Class.forName("oracle.jdbc.driver.OracleDriver");

         Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","pac","mca"); 

         Statement stmt=con.createStatement();
         Statement stmt2=con.createStatement();
		String str=null;
         ResultSet rs = stmt.executeQuery("SELECT student_id student_register WHERE student_id='"+student_id+"'");
		 ResultSet rs5 = stmt2.executeQuery("SELECT company_name from company_register");
          
         if(rs.next())

         {
                      
        ResultSet rs2=stmt.executeQuery("SELECT *FROM student_register WHERE student_id='"+student_id+"'");

        while(rs2.next())
        {
            student_name = rs2.getString(1);
            student_id = rs2.getString(2);
            college_code = rs2.getString(3);         
            course = rs2.getString(4);  

      }
            
          ResultSet rs3=stmt.executeQuery("SELECT *FROM student_marks WHERE student_id='"+student_id+"'");

        while(rs3.next())
        {
            ssc = rs3.getString(1);
            ssc_year = rs3.getString(2);
            inter = rs3.getString(3);         
            inter_year = rs3.getString(4);     
            graduation = rs3.getString(5);
            graduation_year = rs3.getString(6);
            pg = rs3.getString(7);         
            pg_year = rs3.getString(8); 
                             
        }


		 
		 
		 
        out.println("<html><head><script src='show.js'></script></head> ");
      out.println("<body background=\"t5.jpg\">"); 

out.println("<br><h1> <font color=\"white\"> "+student_name+" </font> </h1> ");
     out.println("<br> <br> <br> ");

     out.println("<table cellspacing='3'>");

        out.println("<tr>");
              out.println(" <td> <b> <font color=\"black\"> Id  </font> </b>");
              out.println("<td> <b> <font color=\"white\"> :"+student_id+" </font> </b>");
        out.println("</tr>");

        out.println("<tr>");
              out.println(" <td> <b> <font color=\"black\"> College Code  </font> </b>");
              out.println("<td> <b> <font color=\"white\"> :"+college_code+" </font> </b>");
        out.println("</tr>");

        out.println("<tr>");
              out.println(" <td> <b> <font color=\"black\"> Course  </font> </b>");
              out.println("<td> <b> <font color=\"white\"> :"+course+" </font> </b>");
        out.println("</tr>");   
     
        out.println("<tr>");
              out.println(" <td> <b> <font color=\"black\"> SSC Marks Percentage </font>  </b>");
              out.println("<td> <b> <font color=\"white\"> :"+ssc+" </font> </b>");
        out.println("</tr>");

        out.println("<tr>");
              out.println(" <td> <b> <font color=\"black\"> Year of Passing  </font> </b>");
              out.println("<td> <b> <font color=\"white\"> :"+ssc_year+" </font> </b>");
        out.println("</tr>");

        out.println("<tr>");
              out.println(" <td> <b> <font color=\"black\">Intermediate Marks Percentage </font>  </b>");
              out.println("<td> <b> <font color=\"white\"> :"+inter+" </font> </b>");
        out.println("</tr>");

        out.println("<tr>");
              out.println(" <td> <b> <font color=\"black\">Year of Passing  </font> </b>");
              out.println("<td> <b> <font color=\"white\"> :"+inter_year+" </font> </b>");
        out.println("</tr>");

        out.println("<tr>");
              out.println(" <td> <b> <font color=\"black\">Degree Marks Percentage  </font> </b>");
              out.println("<td> <b> <font color=\"white\"> :"+graduation+" </font> </b>");
        out.println("</tr>");

        out.println("<tr>");
              out.println(" <td> <b> <font color=\"black\">Year of Passing </font>  </b>");
              out.println("<td> <b> <font color=\"white\"> :"+graduation_year+" </font> </b>");
        out.println("</tr>");

        out.println("<tr>");
              out.println(" <td> <b> <font color=\"black\"> PG Marks Percentage </font> </b>");
              out.println("<td> <b> <font color=\"white\"> :"+pg+" </font> </b>");
        out.println("</tr>");

        out.println("<tr>");
              out.println(" <td> <b> <font color=\"black\"> Year of Passing  </font> </b>");
              out.println("<td> <b> <font color=\"white\"> :"+pg_year+" </font> </b>");
              //out.println("<td><b><input type='text' value='"+pg_year+"'/>");
        out.println("</tr>");

     out.println(" </table> ");
     out.println("<br><form method='post' action='es'>");
     out.println("<input type='hidden' name='student_id' value='"+student_id+"'/>");
     out.println("<input type='submit' value='edit'/></form>");
      out.println("<br><br><blink><b><font color='#ffa639' size='6'/>UPDATES</b></blink>");
         ResultSet rs6=stmt.executeQuery("select college_code from message_stu where student_id='"+student_id+"'");
         out.println("<center><table border='1'width='80%'bgcolor='#e0ccff' >");
         
         while(rs6.next())
		  {
		  String college_code=rs6.getString("college_code");
		  
      out.println("<tr><td>");
       
         out.println("<font color='black' size='5'><center>");
        
        
          out.println(college_code+"</center>");
          out.println("</td><td>");
           out.println("<font color='black'size='5'><center> registraions are open :");
         out.println("</center></font></td><td>");
        
     out.println("<form action='sm' method='post' >"+"<input type='hidden'  name='student_id' value='"+student_id+"'>");
     out.println("<input type='submit' value='checkhere'/></form></center></td></tr>");
     
     out.println("</body>");

     out.println("</html>");   
         }
 }
         
  
     }
 
    catch(Exception e)
       {
        // response.sendError(505,e.getMessage());
         e.printStackTrace();
       }    

  }

}  

 